﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Grades
{
    class GradeBook
    {
        public GradeBook()
        {
            _grades = new List<float>();
        }
        // Method is the behavior of the class
        public void AddGrade(float grade)
        {
            if (grade >= 0 && grade <= 100)
            {
                _grades.Add(grade);
            }
        }

        public GradeStatistics ComputeStatistics()
        {
            GradeStatistics stats = new GradeStatistics();

            var sum = 0f;
            foreach (var grade in _grades)
            {
                stats.HigherGrade = Math.Max(grade, stats.HigherGrade);
                stats.HigherGrade = Math.Min(grade, stats.LowestGrade);
                sum += grade;
            }

            stats.Average = sum / _grades.Count;

            return stats;
        }

        //Fields
        //Class Field is the State of the class
        List<float> _grades;


    }
}
